<template>
  <div class="block">
    <el-date-picker
      v-model="value1"
      type="datetimerange"
      range-separator="-"
      start-placeholder="开始时间"
      end-placeholder="截止时间"
      value-format="YYYY-MM-DD HH:mm:ss"
      @change="changTime"
    />
  </div>
</template>
<script lang="ts" setup>
import {
  ref,
  onMounted,
  computed,
  inject,
  reactive,
  onBeforeUnmount,
} from "vue";
import { useRegion } from "@/store/backend/SysM/region";
import { TableColumn, TableRow } from "@/utils/baTable";
import { TableColumnCtx } from "element-plus/es/components/table/src/table-column/defaults";
import type baTableClass from "@/utils/baTable";
import useCurrentInstance from "@/utils/useCurrentInstance";
import { useRoute, useRouter } from "vue-router";

const baTable = inject("baTable") as baTableClass;
const cascader = ref();
const region = useRegion();
const { proxy } = useCurrentInstance();
const route = useRoute();
const router = useRouter();

const state: {} = reactive({});
const value1 = ref<[Date, Date]>([new Date(), new Date()]);

// BuildAdmin将自动为此组件传递五个Props
interface Props {
  renderValue: any; // 单元格值
  renderRow: TableRow; // 当前行数据
  renderField: TableColumn; // 当前列数据
}
const propsBA = withDefaults(defineProps<Props>(), {
  renderValue: () => {
    const region = useRegion();
    return region.regionIds + "";
  },
});

const changTime = (value: any) => {
  console.log("用户确认选定的值时触发", value);
};

proxy.eventBus.on("clearCheckedNodes", () => {
  cascader.value.panel.clearCheckedNodes(); //清空选中的节点
  cascader.value.panel.activePath = []; // 设置为空可以让节点不高亮显示
  // if (JSON.stringify(route.query) !== "{}") {
  //   route.query = {};
  // }
});
// console.log(propsBA.renderValue, propsBA.renderRow, propsBA.renderField);

onMounted(() => {
  region.getRegionByRole().then((res: any) => {});
});
onBeforeUnmount(() => {
  proxy.eventBus.off("clearCheckedNodes");
});
</script>
<style lang="scss" scoped></style>
